package com.taikang.t.service.security.util;

import org.springframework.security.context.SecurityContextHolder;
import org.springframework.security.userdetails.UserDetails;

public class SecurityUserHolder {
	 /** 
	      * Returns the current user 
	      *  
	      * @return 
	      */  
	     public static String getCurrentUserName() {  
	    	 Object obj = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
	    	 if (obj instanceof UserDetails) {
	    	 return  ((UserDetails)obj).getUsername();
	    	 } else {
	    		 return obj.toString();
	    	 }
	         
	     } 
}
